const app = getApp();
import api from "../../api/api"
Page({
  data: {
    navBarHeight: app.globalData.navBarHeight,
    show:true,
    status:1,
    searchCondition: "",
    materiallist:[],
    companyid:""
  },

  serachClick() {
    let that=this
    that.getmateriallist()
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that=this
    let value = wx.getStorageSync('companyid')
    that.setData({
      companyid:value
    })
    
    },

  //获取物流信息
  getmateriallist() {
    try {
     let that = this;
     api.post('/app/logistics/getOrderInfo', {shippingOrderNumber:that.data.searchCondition})
     .then(res => {
       if (res.data){
        wx.navigateTo({
          url: `/pages/orderDetail/orderDetail?shippingOrderNumber=`+that.data.searchCondition,
        })
        setTimeout(function() {
          wx.showToast({
            icon:'none',
            title: "查询成功",
            duration: 1000
         });
       }, 500);
      }else{
        wx.showToast({
          icon:'none',
          title: "未查询到数据",
          duration: 1000
       });
      }
     })
    } catch (error) {
    }
 },

  onChangeinput(event) {
    // event.detail 为当前输入的值
    let that=this
    that.setData({
      searchCondition:event.detail
    })
    // that.getmateriallist()
  },
  // clearSearch(){
  //   let that=this
  //   that.getmateriallist()
  // },
  goToDetail(data){
    let shippingOrderNumber = data.currentTarget.dataset.index
    wx.navigateTo({
      url: `/pages/orderDetail/orderDetail?shippingOrderNumber=`+shippingOrderNumber,
      success: function(res) {
        // 通过eventChannel向被打开页面传送数据
        res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow(){
    let that = this
    if (typeof that.getTabBar === 'function' && that.getTabBar()) {
      that.getTabBar().setData({
        // 根据tab的索引顺序是1
        select: 0
      })
    }
  }
})